The goal of this project is to create a visualization of the progression of past epidemic or pandemic viruses throughout their lifetimes. In doing this, we hope to be able to provide a better understanding of not only the rate at which these types of viruses can spread throughout the population, but also the time it takes for scientists to develop and distribute a vaccine or cure for the spreading virus.
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
##
## Attaching package: 'geojsonio'
## The following object is masked from 'package:base':
##
## pretty
## here() starts at /Users/josefigueroa/Documents/Interactive Visualization/Project
Dimensions:
H1N1.df <- here("Data", "Pandemic (H1N1) 2009.csv") %>%
read.csv()
H1N1.df$Country <- as.character(H1N1.df$Country)
Grand.total.df <- H1N1.df %>% filter(Country == "Grand Total")
H1N1.df <- H1N1.df %>% filter(Country != "Grand Total")
Dataframe Summary:
glimpse(H1N1.df)
## Observations: 1,801
## Variables: 4
## $ Country <chr> "Algeria", "Antigua and Barbuda", "Argentina", "Australia…
## $ Cases <int> 5, 2, 2485, 5298, 19, 7, 15, 18, 12, 54, 1, 416, 1, 737, …
## $ Deaths <int> 0, 0, 60, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2…
## $ Update.Time <fct> 7/6/09 9:00, 7/6/09 9:00, 7/6/09 9:00, 7/6/09 9:00, 7/6/0…
summary(H1N1.df)
## Country Cases Deaths Update.Time
## Length:1801 Min. : 1.0 Min. : 0.000 7/6/09 9:00 : 135
## Class :character 1st Qu.: 3.0 1st Qu.: 0.000 7/3/09 9:00 : 125
## Mode :character Median : 13.0 Median : 0.000 7/1/09 9:00 : 120
## Mean : 475.3 Mean : 2.269 6/29/09 9:00: 116
## 3rd Qu.: 81.0 3rd Qu.: 0.000 6/26/09 7:00: 112
## Max. :33902.0 Max. :170.000 6/24/09 7:00: 108
## NA's :1 (Other) :1085
Head:
head(H1N1.df)
| Country | Cases | Deaths | Update.Time |
|---|---|---|---|
| Algeria | 5 | 0 | 7/6/09 9:00 |
| Antigua and Barbuda | 2 | 0 | 7/6/09 9:00 |
| Argentina | 2485 | 60 | 7/6/09 9:00 |
| Australia | 5298 | 10 | 7/6/09 9:00 |
| Austria | 19 | 0 | 7/6/09 9:00 |
| Bahamas | 7 | 0 | 7/6/09 9:00 |
Tail:
tail(H1N1.df)
| Country | Cases | Deaths | Update.Time | |
|---|---|---|---|---|
| 1796 | Sweden | 3 | 0 | 5/23/09 8:00 |
| 1797 | Switzerland | 2 | 0 | 5/23/09 8:00 |
| 1798 | Thailand | 2 | 0 | 5/23/09 8:00 |
| 1799 | Turkey | 2 | 0 | 5/23/09 8:00 |
| 1800 | United Kingdom | 117 | 0 | 5/23/09 8:00 |
| 1801 | United States of America | 6552 | 9 | 5/23/09 8:00 |
Unique Dates:
unique.dates <- levels(H1N1.df$Update.Time)
length(unique.dates)
## [1] 22
unique.dates
## [1] "5/23/09 8:00" "5/25/09 8:00" "5/26/09 6:00" "5/27/09 8:00"
## [5] "5/29/09 6:00" "6/1/09 6:00" "6/10/09 6:00" "6/11/09 14:00"
## [9] "6/12/09 7:00" "6/15/09 17:00" "6/17/09 12:00" "6/19/09 7:00"
## [13] "6/22/09 7:00" "6/24/09 7:00" "6/26/09 7:00" "6/29/09 9:00"
## [17] "6/3/09 6:00" "6/5/09 6:00" "6/8/09 6:00" "7/1/09 9:00"
## [21] "7/3/09 9:00" "7/6/09 9:00"
There are 22 unique weeks to account for. We should look into how to plot on a world map style heatmap (I have an idea on this), and then allowing for the option to traverse time on said heatmap. We can also easily transorm this notebook into a webapp with RShiny
For this week, we can probably focus on having just 1 week plotted (5/23/2009). Then we can generalize to be interactive through time
country.shapes <- here("Data", "countries.geojson") %>%
geojson_read(what = "sp")
CASES <- as.data.frame(country.shapes$ADMIN)
colnames(CASES) <- c("Country")
rownames(CASES) <- CASES$Country
CASES$Cases <- 0
CASES[H1N1.df[H1N1.df$Update.Time == "5/23/09 8:00","Country"], "Cases"] <-
H1N1.df[H1N1.df$Update.Time == "5/23/09 8:00","Cases"]
pal <- colorNumeric(
palette = "Reds",
domain = country.shapes$CASES
)
country.shapes$CASES <- CASES$Cases
leaflet(options=leafletOptions(minZoom=2, maxZoom=18)) %>%
setView(-96.8, 39, 4) %>%
addTiles()
## May 23 2009
m <- country.shapes %>%
leaflet() %>%
addPolygons(
stroke=FALSE,
smoothFactor = 0.2,
fillOpacity = 0.7,
color = ~pal(CASES)
)%>%
setView(-96.8, 39, 4)
m